package pe.gob.reniec.cel.web;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import pe.gob.reniec.cel.model.Persona;
import pe.gob.reniec.cel.service.PersonaService;

/**
 *
 * @author Lennon Shimokawa
 */
@Controller
public class PersonaController {

    private static final Logger logger = Logger.getLogger(PersonaController.class);

    @Autowired
    private PersonaService personaService;

    @RequestMapping("/consultarPorDni/inicio.htm")
    public ModelAndView inicio() {
        logger.debug("inicio");
        return new ModelAndView("consultarPorDni", "persona", new Persona());
    }

    @RequestMapping("/consultarPorDni/consultar.htm")
    public ModelAndView consultar(Persona personaReq) {
        logger.debug("consultar");
        logger.debug("dni="+personaReq.getDni());
        Persona persona = personaService.consultarPorDni(personaReq.getDni());
        logger.debug("nombre="+persona.getNombre());
        return new ModelAndView("consultarPorDni", "persona", persona);
    }
}










